
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
 */
package meeple;

/**
 *
 * @author rogier
 */
public enum Position {
    top_left(0, 8, 0, 0, 1), top(0, 21, 0, 0, 1), top_right(2, 33, 0, 0, 1), right_up(3, 42, 8, 1, 0),
    right(4, 42, 21, 1, 0), right_down(5, 42, 33, 1, 0), bottom_left(6, 33, 42, 0, -1), bottom(7, 21, 42, 0, -1),
    bottom_right(8, 8, 42, 0, -1), left_down(9, 0, 33, -1, 0), left(10, 0, 21, -1, 0), left_up(11, 0, 8, -1, 0),
    center(12, 21, 21, 0, 0),
    none(-1, 0, 0, 0, 0);

    private final int index;
    private final int offset_x;
    private final int offset_y;
    private final int x;
    private final int y;

    Position(int index, int offset_x, int offset_y, int x, int y) {
        this.index    = index;
        this.offset_x = offset_x;
        this.offset_y = offset_y;
        this.x        = x;
        this.y        = y;
    }

    int arrayIndex() {
        return index;
    }

    int offsetX() {
        return offset_x;
    }

    int offsetY() {
        return offset_y;
    }

    int X() {
        return x;
    }

    int Y() {
        return y;
    }

    static Position Opposite(Position p) {
        Position result;

        switch (p) {
        case top_left :
            result = bottom_left;

            break;

        case top :
            result = bottom;

            break;

        case top_right :
            result = bottom_right;

            break;

        case right_up :
            result = left_up;

            break;

        case right :
            result = left;

            break;

        case right_down :
            result = left_down;

            break;

        case bottom_left :
            result = top_left;

            break;

        case bottom :
            result = top;

            break;

        case bottom_right :
            result = top_right;

            break;

        case left_down :
            result = right_down;

            break;

        case left :
            result = right;

            break;

        case left_up :
            result = right_up;

            break;

        case center :
            result = center;

            break;

        case none :
            result = none;

            break;

        default :
            result = none;
        }

        return result;
    }

    static Position rotatetPosition(Position p) {
        Position result;

        switch (p) {
        case top_left :
            result = right_up;

            break;    // bottom_left;break;

        case top :
            result = right;

            break;

        case top_right :
            result = right_down;

            break;

        case right_up :
            result = bottom_right;

            break;

        case right :
            result = bottom;

            break;

        case right_down :
            result = bottom_left;

            break;

        case bottom_left :
            result = left_up;

            break;

        case bottom :
            result = left;

            break;

        case bottom_right :
            result = left_down;

            break;

        case left_down :
            result = top_left;

            break;

        case left :
            result = top;

            break;

        case left_up :
            result = top_right;

            break;

        case center :
            result = center;

            break;

        case none :
            result = none;

            break;

        default :
            result = none;
        }

        return result;
    }

    static Position rotateCctPosition(Position p) {
        Position result;

        switch (p) {
        case top_left :
            result = left_down;

            break;

        case top :
            result = left;

            break;

        case top_right :
            result = left_up;

            break;

        case right_up :
            result = top_left;

            break;

        case right :
            result = top;

            break;

        case right_down :
            result = top_right;

            break;

        case bottom_left :
            result = top_left;

            break;

        case bottom :
            result = right;

            break;

        case bottom_right :
            result = top_right;

            break;

        case left_down :
            result = right_down;

            break;

        case left :
            result = bottom;

            break;

        case left_up :
            result = right_up;

            break;

        case center :
            result = center;

            break;

        case none :
            result = none;

            break;

        default :
            result = none;
        }

        return result;
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
